
#include "Protocol.h"

namespace zmh
{
    class cal
    {
    public:
        zmh::Response operator()(zmh::Request req)
        {
            switch (req.Oper())
            {
            case '+':
                return zmh::Response(req.X() + req.Y());
                break;
            case '-':
                return zmh::Response(req.X() - req.Y());
                break;
            case '*':
                return zmh::Response(req.X() * req.Y());
                break;
            case '/':
                if (req.Y() == 0)
                    return zmh::Response(0, 1);
                else
                    return zmh::Response(req.X() / req.Y());
                break;
            case '%':
                if (req.Y() == 0)
                    return zmh::Response(0, 2);
                else
                    return zmh::Response(req.X() % req.Y());
                break;
            default:
                return zmh::Response(0, 3);
                break;
            }
        }
    };
}
